package tp.model;

import tp.util.DateTool;

public class Ticket {

	private String nom;
	private String place;
	private Trajet trajet;
	private Client client;
	private double prix;

	public double getPrix() {
		if (prix < 0) {
			calculPrix();
		}
		return prix;
	}

	public Ticket() {
		prix = -1;
	}

	public void setPrix(double prix) {
		this.prix = prix;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Ticket(String place, Trajet trajet, Client client) {
		this.place = place;
		this.trajet = trajet;
		this.client = client;
	}

	public String getPlace() {
		return this.place;
	}

	public void setPlace(String place) {
		this.place = place;
	}

	public Trajet getTrajet() {
		return this.trajet;
	}

	public void setTrajet(Trajet trajet) {
		this.trajet = trajet;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	private void calculPrix() {
		// FIXME calculer le prix
		prix = 100;
	}

	public String toString() {
		return "ticket : " + nom + "\n\tde" + trajet.getDepart().getNom()
				+ " vers : " + trajet.getArrivee().getNom() + " le : "
				+ DateTool.printDate(trajet.getDate(), DateTool.DATE_FORMAT);
	}
}